﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel.Composition;
using Microsoft.Practices.Prism.Regions;

namespace EIA.SLClient.ProjectManage
{
	/// <summary>
	/// LoginView.xaml 的交互逻辑
	/// </summary>
    [Export]
    public partial class LoginView : UserControl, SimpleMvvmToolkit.INotifyable
    {
        public LoginView()
        {
            this.InitializeComponent();

            SimpleMvvmToolkit.MessageBus.Default.Register(EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.LOGIN_SHOW, this);
        }

        [Import]
        public IRegionManager RegionManager;


        private void PasswordBox_PasswordChanged(object sender, System.Windows.RoutedEventArgs e)
        {
            // 在此处添加事件处理程序实现。
            ((sender as PasswordBox).DataContext as LoginViewModel).Password = (sender as PasswordBox).Password;
        }

        void SimpleMvvmToolkit.INotifyable.Notify(string token, object sender, SimpleMvvmToolkit.NotificationEventArgs e)
        {
            switch (token)
            {
                case EIA.SLClient.ProjectManage.Infrastructure.MessageTokens.LOGIN_SHOW:
                    RegionManager.RequestNavigate(EIA.SLClient.ProjectManage.Infrastructure.RegionNames.OverlayRegion, typeof(LoginView).FullName);
                    break;
            }
        }
    }
}